#Nick Glyder, 2014
#This shell script will run the C++ version to compute the NQueens problem 
#and then pipe the info to the Java GUI for display purposes

FILE1="bin/driver.class"
FILE2="bin/chessBoard.class"

#Make sure we have proper number of arguments
if [ $# -ne 2 ]
    then
    echo "USAGE: bash ./NQGUI <N = size of problem> <K = number of desired solutions>"
    exit 1
fi

echo "Running NQueens Suite"
#Always compile C code
g++ -o nqueensC src/nqueens.cpp -g -Wall

#Check if class files already exist
if [ -f $FILE1 ] && [ -f $FILE2 ]
    then
    echo "Java class files already exist..."
    else    #if not, compile
    javac -cp . src/*.java -d bin/
fi

./nqueensC $1 $2
java -cp ./bin driver $1
echo "GUI Terminated, closing..."
